Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix writing-tests.md reference to enable_factory_create #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yoomlam
Copy link
Contributor

@yoomlam yoomlam commented Jul 16, 2024

Ticket

Small documentation correction to be consistent with code.

Changes

In order to use the create strategy, pull in the `initialize_factories_session`

refers to initialize_factories_session but should be enable_factory_create

Testing

Compare with

The application uses [Factory Boy](https://factoryboy.readthedocs.io/en/stable/) to generate test data for the application. This can be used to create models `Factory.build` that can be used in any test, or to prepopulate the database with persisted models using `Factory.create`. In order to use `Factory.create` to create persisted database models, include the `enable_factory_create` fixture in the test.

and
def enable_factory_create(monkeypatch, db_session) -> db.Session:
"""
Allows the create method of factories to be called. By default, the create
throws an exception to prevent accidental creation of database objects for tests
that do not need persistence. This fixture only allows the create method to be
called for the current test. Each test that needs to call Factory.create should pull in
this fixture.
"""

@yoomlam yoomlam requested a review from chouinar July 16, 2024 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant